﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;

using AtletIS.DomainModel.Entities.Main;
using AtletIS.Service.Services;
using AtletIS.UI.Messaging;
using AtletIS.UI.ViewModels.Base;

namespace AtletIS.UI.ViewModels
{
    public class DisciplineListViewModel : MediatorViewModelBase<ViewModelMessages>
    {

        #region Properties

        private DisciplineList _activeDisciplineList;
        
        public List<DisciplineList> DisciplineList { get; set; }
        
        public DisciplineList ActiveDisciplineList 
        {
            get { return _activeDisciplineList; }
            set
            {
                _activeDisciplineList = value;
                OnPropertyChanged("ActiveDisciplineList");
                base.Mediator.NotifyColleagues(ViewModelMessages.ActiveDisciplineListChanged, this.ActiveDisciplineList);
            }
        }

        #endregion

        #region Constructor

        public DisciplineListViewModel(Competition competition)
        {
            if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                using (var service = new DisciplineListService())
                {
                    this.DisciplineList = service.GetByCompetitionId(competition.ID);
                    if (this.DisciplineList != null && this.DisciplineList.Count > 0)
                    {
                        this.ActiveDisciplineList = this.DisciplineList[0];
                    }
                }
            }
        }

        #endregion





    }
}
